package com.itboye.textileexpes.repository;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.gson.reflect.TypeToken;
import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.textileexpes.beans.GoodsBean;
import com.itboye.textileexpes.beans.GoodsTopBean;
import com.itboye.textileexpes.beans.UserBean;
import com.itboye.textileexpes.beans.YoufeiBean;
import com.itboye.textileexpes.interfaces.IYouFei;
import com.itboye.textileexpes.json.ByJsonRequest.Builder;
import com.itboye.textileexpres.base.BaseErrorListener;
import com.itboye.textileexpres.base.BaseNetRepository;
import com.itboye.textileexpres.base.BaseSuccessReqListener;

public class YouFeiRepository extends BaseNetRepository implements
		IYouFei<YoufeiBean> {
	public static String youfeiNow = "By_Freight_calcNow";
	public static String youfeishopcar = "By_Freight_calc";
	//商品不感兴趣
	public static String Product = "By_Product_dislike";

	public YouFeiRepository(ICompleteListener listener) {
		super(listener);
	}

	public void getYouFei(String uid, String count, String sku_pid,
			String address_id) {
		Type type = new TypeToken<List<YoufeiBean>>() {
		}.getType();
		String apiVer = "100";
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("uid", uid);
		map.put("count", count);
		map.put("sku_pkid", sku_pid);
		map.put("address_id", address_id);
		(new Builder<List<YoufeiBean>>())
				.setTypeVerParamsAndReturnClass(youfeiNow, apiVer, map, type)
				.requestListener(
						new BaseSuccessReqListener<List<YoufeiBean>>(
								getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}

	@Override
	public void add(YoufeiBean model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void delete(YoufeiBean model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(YoufeiBean model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void getInfo(YoufeiBean model) {
		// TODO Auto-generated method stub

	}

	@Override
	public List<YoufeiBean> query(YoufeiBean model) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void shopcarYouFei(String uid, String ids, String address_id) {
		// TODO Auto-generated method stub
		Type type = new TypeToken<List<YoufeiBean>>() {
		}.getType();
		String apiVer = "100";
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("uid", uid);
		map.put("ids", ids);
		map.put("address_id", address_id);
		(new Builder<List<YoufeiBean>>())
				.setTypeVerParamsAndReturnClass(youfeishopcar, apiVer, map,
						type)
				.requestListener(
						new BaseSuccessReqListener<List<YoufeiBean>>(
								getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();

	}

	@Override
	public void onProduct(String id, String uid) {
		// TODO Auto-generated method stub
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = "100";
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("id", id);
		map.put("uid", id);
		(new Builder<String>())
				.setTypeVerParamsAndReturnClass(Product, apiVer, map,
						type)
				.requestListener(
						new BaseSuccessReqListener<String>(
								getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}
}
